package JLabel_JTextField_JPasswordField_JButton;
import javax.swing.*;

public class MyFrame extends JFrame{
    public MyFrame()
    {
        this.setSize(350,200);
        this.setTitle("这是第一个JFrame程序.");
        this.setLayout(null); // 将JFrame的布局设置为空，通过坐标定位
        JLabel j1 = new JLabel("账号:");
        JLabel j2 = new JLabel("密码:");
        JTextField uTxt = new JTextField(20);
        JPasswordField pTxt = new JPasswordField(20);
        JButton btn = new JButton("登入");
        j1.setBounds(30,55,60,26);
        j2.setBounds(30,80,60,26);
        uTxt.setBounds(95,55,120,26);
        pTxt.setBounds(95,80,120,26);
        btn.setBounds(150,110,60,30);
        this.add(j1);
        this.add(j2);
        this.add(uTxt);
        this.add(pTxt);
        this.add(btn);
        this.setLocationRelativeTo(null); // 使窗口居中
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // 响应窗口关闭按钮
        this.setVisible(true); // 将窗口显示出来
    }
    public static void main(String[] args)
    {
        new MyFrame();
    }
}
